<?php

	App::import('Lib', 'pheme/bridge');

	class ThemeView extends View
	{
		function __construct (&$controller)
		{
			parent::__construct($controller);
			$this->theme =& $controller->theme;
	
			if (!empty($this->theme)) {
				if (is_dir(WWW_ROOT . 'themed' . DS . $this->theme)) {
					$this->themeWeb = 'themed/'. $this->theme .'/';
				}
				/* deprecated: as of 6128 the following properties are no longer needed */
				$this->themeElement = 'themed'. DS . $this->theme . DS .'elements'. DS;
				$this->themeLayout =  'themed'. DS . $this->theme . DS .'layouts'. DS;
				$this->themePath = 'themed'. DS . $this->theme . DS;
			}
		}

		function _paths($plugin = null, $cached = true)
		{
			$paths = parent::_paths($plugin, $cached);
	
			if (!empty($this->theme)) {
				$count = count($paths);
				for ($i = 0; $i < $count; $i++) {
					$themePaths[] = $paths[$i] . 'themed'. DS . $this->theme . DS;
				}
				$paths = array_merge($themePaths, $paths);
			}
	
			if (empty($this->__paths)) {
				$this->__paths = $paths;
			}
	
			return $paths;
		}
	}